#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#define maxn 100

using namespace std;

class Student
{
public:
    Student(int room, string name, int height, int weight)
    {
        this->room = room;
        this->name = name;
        this->height = height;
        this->weight = weight;
    }

    Student() {}

    int room;
    string name;
    int height;
    int weight;
};

bool cmp(Student a, Student b)
{
    if (a.room != b.room)
        return a.room < b.room;
    else
        return a.height < b.height;
}

Student s[maxn];
int main()
{
    int n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        int ro, hei, wei;
        string sname;
        cin >> ro >> sname >> hei >> wei;
        s[i] = Student(ro, sname, hei, wei);
    }

    sort(s, s + n, cmp);

    int i = 0;
    while (i < n)
    {
        int j = i + 1;
        while (s[i].room == s[j].room)
            j++;
        i = j;
        printf("%06d ", s[j - 1].room);
        cout << s[j - 1].name << " " << s[j - 1].height << " " << s[j - 1].weight << endl;
    }
    return 0;
}